package com.example.pingze.service;

import com.example.pingze.entity.Comment;
import com.example.pingze.repository.CommentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService {
    @Autowired
    private CommentRepository commentsRepository;

    public Comment addComment(Comment comment) {
        return commentsRepository.save(comment);
    }

    public List<Comment> findCommentsByCreationId(String creationId) {
        List<Comment> comments = commentsRepository.findCommentByCreationId(creationId);
        return comments;
    }

    public Comment findCommentById(String commentId) {
        return commentsRepository.findCommentById(commentId);
    }

    public void saveComment(Comment comment) {
        commentsRepository.save(comment);
    }

    public void deleteCreation(Comment comment) {
        commentsRepository.delete(comment);
    }
}
